﻿using System;
using System.Data;
using System.Data.OracleClient;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

public partial class Support_BlackList : BasicPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SetPager();
        }
    }

    protected void BlackPager_PageChanged(object sender, EventArgs e)
    {
        SetPager();
    }

    protected void BlackList_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Charge")
        {
            string sqlstr = "DELETE FROM BLACK_LIST WHERE CELL_NAME=:CELL_NAME";
            OracleParameter[] _params = {
                new OracleParameter(":CELL_NAME",OracleType.NVarChar,40)
            };
            _params[0].Value = e.CommandArgument.ToString();
            OracleHelper.ExecuteNonQuery(sqlstr, CommandType.Text, _params);
            SetPager();
            JQueryAlert("取消成功！");            
        }
    }

    private void SetPager()
    {
        PagedDataSource pds = new PagedDataSource();
        DataSet ds = GetBlack();
        BlackPager.RecordCount = ds.Tables[0].Rows.Count;
        pds.DataSource = ds.Tables[0].DefaultView;
        pds.AllowPaging = true;
        pds.PageSize = BlackPager.PageSize;
        pds.CurrentPageIndex = BlackPager.CurrentPageIndex - 1;
        BlackList.DataSource = pds;
        BlackList.DataBind();
    }

    private DataSet GetBlack()
    {
        string sqlstr = "SELECT CELL_NAME,ADD_DATE FROM BLACK_LIST ORDER BY ADD_DATE DESC";
        return OracleHelper.ExecuteDataSet(sqlstr, CommandType.Text, null);
    }
}
